<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>LayTp</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <!-- 加载公用css文件 -->
    {include file="admin@public/layout/file/css_file"}
</head>
<body class="laytp-theme-{$theme}">
<div class="popup-content">
    <form class="layui-form layui-form-pane page-list-form">
        <div class="layui-form-item">
            <label class="layui-form-label" title="标题">登录密码</label>
            <div class="layui-input-block">
                <input type="password" id="password" name="password" placeholder="输入登录密码解锁" class="layui-input" lay-verify="required" lay-verType="tips">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <a class="layui-btn layui-btn-normal" lay-submit lay-filter="unlock_screen" id="unlock_screen">确 定</a>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript" src="__STATIC__/library/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['jquery','form'],function(){
        const $ = layui.jquery;
        layui.form.on('submit(unlock_screen)', function(data){
            let password = $('#password').val();
            if(!password){
                layui.layer.msg('密码不能为空',{icon:2});
                return false;
            }
            $.post('',{password:password},function(res){
                if(res.code == 1){
                    localStorage.removeItem('laytp_lock_screen');
                    parent.location.reload();
                }else{
                    layui.layer.msg(res.msg,{icon:2});
                }
            });
            return false;
        });

        document.onkeydown = function (e) {
            e = e ? e : event;// 兼容FF
            if (e.keyCode == 13) {
                $("#unlock_screen").click();//提交按钮的id
                return false;//防止页面跳转刷新掉
            }
        }
    });
</script>
</body>
</html>